feat(auth): implement proactive SIWE session expiry warning banner (#226) - #321
Merged
Lakes41 merged 1 commit intoJul 25, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #226
This PR introduces a proactive, dismissible warning banner for SIWE administrative sessions before the access token expires. Previously, session expiration only triggered an error banner after a failed mutation request (401), causing administrators to lose in-progress work (such as active edits in the Policy Editor).
Now, administrators are notified ahead of time with a live countdown and can extend their session with a single click before any requests fail.
Changes Included
lib/session.ts):DEFAULT_WARNING_THRESHOLD_SECONDS(120s / 2m).getRemainingSessionSeconds(),isSessionExpiringSoon(), andformatTimeRemaining()helpers.lib/config.ts):warningThresholdSecondstoSiweConfig, populated via environment variables (NEXT_PUBLIC_SIWE_WARNING_MINUTESorNEXT_PUBLIC_SIWE_WARNING_SECONDS), defaulting to 2 minutes.lib/wallet/siwe-context.ts&lib/wallet/providers.tsx):isExpiringandwarningThresholdSecondsthroughSiweAuthContext.SiweAuthContextinstance between definition module and provider tree.components/admin-guard.tsx):role="status",aria-live="polite",aria-label="Extend your signed-in session") warning banner whenisExpiringis active.{currentSeconds}s), anExtend Sessionaction button, and aDismissoption.test/siwe-proactive-warning.test.ts):AdminGuardrender behavior.Verification
npm run test: 497 tests across 93 suites passed with 0 failures.